home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / tcl / tcl70b2.lha / tcl7.0b2 / tests / lreplace.test < prev    next >
Text File  |  1993-02-06  |  4KB  |  107 lines

  1. # Commands covered:  lreplace
  2. #
  3. # This file contains a collection of tests for one or more of the Tcl
  4. # built-in commands.  Sourcing this file into Tcl runs the tests and
  5. # generates output for errors.  No output means no errors were found.
  6. #
  7. # Copyright (c) 1991-1993 The Regents of the University of California.
  8. # All rights reserved.
  9. #
  10. # Permission is hereby granted, without written agreement and without
  11. # license or royalty fees, to use, copy, modify, and distribute this
  12. # software and its documentation for any purpose, provided that the
  13. # above copyright notice and the following two paragraphs appear in
  14. # all copies of this software.
  15. #
  16. # IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
  17. # DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
  18. # OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
  19. # CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  20. #
  21. # THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
  22. # INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  23. # AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
  24. # ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
  25. # PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  26. #
  27. # $Header: /user6/ouster/tcl/tests/RCS/lreplace.test,v 1.5 93/02/06 16:01:39 ouster Exp $ (Berkeley)
  28.  
  29. if {[string compare test [info procs test]] == 1} then {source defs}
  30.  
  31. test lreplace-1.1 {lreplace command} {
  32.     lreplace {1 2 3 4 5} 0 0 a
  33. } {a 2 3 4 5}
  34. test lreplace-1.2 {lreplace command} {
  35.     lreplace {1 2 3 4 5} 1 1 a
  36. } {1 a 3 4 5}
  37. test lreplace-1.3 {lreplace command} {
  38.     lreplace {1 2 3 4 5} 2 2 a
  39. } {1 2 a 4 5}
  40. test lreplace-1.4 {lreplace command} {
  41.     lreplace {1 2 3 4 5} 3 3 a
  42. } {1 2 3 a 5}
  43. test lreplace-1.5 {lreplace command} {
  44.     lreplace {1 2 3 4 5} 4 4 a
  45. } {1 2 3 4 a}
  46. test lreplace-1.6 {lreplace command} {
  47.     lreplace {1 2 3 4 5} 4 5 a
  48. } {1 2 3 4 a}
  49. test lreplace-1.7 {lreplace command} {
  50.     lreplace {1 2 3 4 5} -1 -1 a
  51. } {a 2 3 4 5}
  52. test lreplace-1.8 {lreplace command} {
  53.     lreplace {1 2 3 4 5} 2 end a b c d
  54. } {1 2 a b c d}
  55. test lreplace-1.9 {lreplace command} {
  56.     lreplace {1 2 3 4 5} 0 3
  57. } {5}
  58. test lreplace-1.10 {lreplace command} {
  59.     lreplace {1 2 3 4 5} 0 4
  60. } {}
  61. test lreplace-1.11 {lreplace command} {
  62.     lreplace {1 2 3 4 5} 0 1
  63. } {3 4 5}
  64. test lreplace-1.12 {lreplace command} {
  65.     lreplace {1 2 3 4 5} 2 3
  66. } {1 2 5}
  67. test lreplace-1.13 {lreplace command} {
  68.     lreplace {1 2 3 4 5} 3 end
  69. } {1 2 3}
  70. test lreplace-1.14 {lreplace command} {
  71.     lreplace {1 2 3 4 5} -1 4 a b c
  72. } {a b c}
  73. test lreplace-1.15 {lreplace command} {
  74.     lreplace {a b "c c" d e f} 3 3
  75. } {a b "c c" e f}
  76. test lreplace-1.16 {lreplace command} {
  77.     lreplace { 1 2 3 4 5} 0 0 a
  78. } {a 2 3 4 5}
  79. test lreplace-1.17 {lreplace command} {
  80.     lreplace {1 2 3 4 "5 6"} 4 4 a
  81. } {1 2 3 4 a}
  82. test lreplace-1.18 {lreplace command} {
  83.     lreplace {1 2 3 4 {5 6}} 4 4 a
  84. } {1 2 3 4 a}
  85.  
  86. test lreplace-2.1 {lreplace errors} {
  87.     list [catch lreplace msg] $msg
  88. } {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
  89. test lreplace-2.2 {lreplace errors} {
  90.     list [catch {lreplace a b} msg] $msg
  91. } {1 {wrong # args: should be "lreplace list first last ?element element ...?"}}
  92. test lreplace-2.3 {lreplace errors} {
  93.     list [catch {lreplace x a 10} msg] $msg
  94. } {1 {expected integer but got "a"}}
  95. test lreplace-2.4 {lreplace errors} {
  96.     list [catch {lreplace x 10 x} msg] $msg
  97. } {1 {bad index "x": must be integer or "end"}}
  98. test lreplace-2.5 {lreplace errors} {
  99.     list [catch {lreplace x 10 1x} msg] $msg
  100. } {1 {expected integer but got "1x"}}
  101. test lreplace-2.6 {lreplace errors} {
  102.     list [catch {lreplace x 3 2} msg] $msg
  103. } {1 {first index must not be greater than second}}
  104. test lreplace-2.7 {lreplace errors} {
  105.     list [catch {lreplace x 1 1} msg] $msg
  106. } {1 {list doesn't contain element 1}}
  107.